<!--  -->
<template>
  <div
    class="lsh-box"
    ref="boxRef">
    <div
      class="lsh-canvas"
      id="canvasBox">
      <div class="lsh-tool-box">
        <div class="lsh-tool-list">
          <IconBtn
            name="scale-shrink"
            @click="setActiveTool('pen')"
            >
          </IconBtn>
          <input
            type="range"
            v-model="config.pen.width"
            min="1"
            max="20" />
            {{activeTool}}
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, watch } from "vue";
import { useDrawing } from "./hooks/useDraw";
import IconBtn from "@/views/canvasSketch/components/icon-btn/index.vue";
const { activeTool, config, setActiveTool } = useDrawing("canvasBox");

// 响应式更新画笔宽度
watch(
  () => config.pen.width,
  (newVal) => {
    console.log("画笔宽度更新:", newVal);
  }
);
</script>
<style scoped lang="less">
.lsh-box {
  position: relative;
  width: 100vw;
  height: 100vh;
  .lsh-tool-box {
    position: absolute;
    z-index: 1;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    display: flex;
    justify-content: center;
    .lsh-tool-list {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 20px;
      flex-wrap: wrap;
      border-radius: 16px;
      background: rgba(0, 0, 0, 0.7);
      backdrop-filter: blur(5px);
      padding: 16px 32px;
      .lsh-pen-btn {
        cursor: pointer;
      }
      .lsh-tool-btn {
        cursor: pointer;
        color: rgba(255, 255, 255, 1);
        color: #fff;
        font-family: "PingFang SC";
        font-size: 14px;
        font-weight: 400;
        display: flex;
        align-items: center;
        gap: 4px;
      }
      .lsh-icon {
        color: #fff;
        font-size: 20px;
      }
      .scale-text {
        width: 38px;
        color: #fff;
        font-family: "PingFang SC";
        font-size: 14px;
        font-weight: 400;
        line-height: normal;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
  }

  .lsh-canvas {
    width: 100vw;
    height: 100vh;
    // position: absolute;
    // z-index: 50;
    background-color: transparent;
    transform: translateZ(0); /* 强制启用硬件加速 */
    border: 1px solid #c2650e;
  }

  .lsh-page {
    width: 100%;
    height: 100%;
    background-color: #c2650e;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
</style>
